This page last changed on Feb 27, 2006 by [email protected].

Tag - select

Description

Helper tag for creating HTML selects.

Parameters

  • from (required) - The list or range to select from
  • value (optional) - The current selected value that evaluates equals() to true for one of the elements in the from list.
  • optionKey (optional) - By default the value attribute of each "option" element will be the result of a "toString()" call on each element in the "from" attribute list. Setting this allows the value of the attribute to be a bean property of each element in the list
  • optionValue (optional) - By default the value "option" element will be the result of a "toString()" call on each element in the "from" attribute list. Setting this allows the value to be a bean property of each element in the list.

Examples

// create a select from a range
<g:select name="user.age" from="${18..65}" value="${age}" />

// create select from a list of companies
// note the 'optionKey' is set to the id of each company element
<g:select name="user.company.id" 
          from="${Company.list()}" 
          value="${user?.company.id}" 
          optionKey="id" />

Example as a method call in GSP only:

${select(from:aList,value:aValue)}
Document generated by Confluence on Mar 29, 2006 08:46